package com.grasscove.namethat.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.grasscove.namethat.R;

public class CategoriesListAdapter extends BaseAdapter {
	private TextView mCategoryText;
	private String[] mCategories;
	private Context mContext;

	public CategoriesListAdapter(Context context, String[] categories) {
		mContext = context;
		mCategories = categories;
	}

	@Override
	public int getCount() {
		return mCategories.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LinearLayout row;

		if (convertView == null) {
			row = new LinearLayout(mContext);

			LayoutInflater vi;
			vi = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
			vi.inflate(R.layout.categories_row, row, true);
		} else {
			row = (LinearLayout) convertView;
		}

		mCategoryText = (TextView) row.findViewById(R.id.categories_row_text);
		mCategoryText.setText(mCategories[position]);

		return row;
	}
}
